import 'package:flutter/material.dart';

class ContentCancelConfirm extends StatelessWidget {
  final String title; // 标题（可选）
  final String message; // 内容（必填）
  final VoidCallback? onCancel; // 取消按钮回调（可选）
  final VoidCallback? onConfirm; // 确认按钮回调（可选）

  const ContentCancelConfirm({
    super.key,
    this.title = '提示',
    required this.message,
    this.onCancel,
    this.onConfirm,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(20), // 外层内边距
      constraints: const BoxConstraints(minHeight: 180), // 最小高度
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          // 标题
          Text(
            title,
            style: const TextStyle(
              fontSize: 20,
              fontWeight: FontWeight.bold,
            ),
            textAlign: TextAlign.center,
          ),

          const SizedBox(height: 16),

          // message 撑满中间空间
          Expanded(
            child: SingleChildScrollView(
              child: Text(
                message,
                style: const TextStyle(fontSize: 16, color: Colors.black87),
                textAlign: TextAlign.center,
              ),
            ),
          ),

          const SizedBox(height: 20),

          // 按钮行（如果至少有一个按钮）
          if (onCancel != null || onConfirm != null)
            Row(
              children: [
                if (onCancel != null)
                  Expanded(
                    child: OutlinedButton(
                      onPressed: onCancel,
                      style: OutlinedButton.styleFrom(
                        padding: const EdgeInsets.symmetric(vertical: 14),
                        side: const BorderSide(color: Colors.grey),
                      ),
                      child: const Text("取消"),
                    ),
                  ),
                if (onCancel != null && onConfirm != null)
                  const SizedBox(width: 12), // 按钮间距
                if (onConfirm != null)
                  Expanded(
                    child: ElevatedButton(
                      onPressed: onConfirm,
                      style: ElevatedButton.styleFrom(
                        padding: const EdgeInsets.symmetric(vertical: 14),
                        backgroundColor: Colors.blueAccent,
                        foregroundColor: Colors.white,
                        shape: RoundedRectangleBorder(
                          borderRadius: BorderRadius.circular(8),
                        ),
                      ),
                      child: const Text("确定"),
                    ),
                  ),
              ],
            ),
        ],
      ),
    );
  }
}


//使用：
//CustomBottomDialog.show(
//context: context,
//width: 300, // 👈 固定宽高
//height: 200,            // 👈 高度可自定义或用 double.infinity
//borderRadius: 20,       // 👈 可设置为 0 取消圆角
//animationType: DialogAnimationType.popup,//底部划出
//builder: (ctx) =>  DialogContentCancelConfirm(title: "提示", message: "你好",
//onConfirm: (){
//Navigator.pop(context);
//}),
//);
//}